import request from '@/utils/request';
import { getCurrentInstance } from 'vue';
const errortips =
  getCurrentInstance()?.appContext.config.globalProperties.$errortips;

/**
 * 分页查询用户
 */
export async function get_order_import_list(params) {
  const res = await request.post('/order/order_import/get_list', {
    ...params
  });
  if (res.data.code === 1) {
    return {
      list: res.data.data.row_list,
      columns: res.data.data.columns,
      searchData: res.data.data.search_area,
      count: res.data.data.page_info?.total,
      top_button: res.data.data.top_button
    };
  }
  return Promise.reject(res.data.msg);
}
export async function import_order(params) {
  const res = await request.post('/order/order_import/import_order', params);
  if (res.data.code === 1) {
    return res.data;
  }
  return Promise.reject(res.data?.msg || errortips);
}
export async function import_refund(params) {
  const res = await request.post('/order/order_import/import_refund', params);
  if (res.data.code === 1) {
    return res.data;
  }
  return Promise.reject(res.data?.msg || errortips);
}
export async function get_order_import_detail(params) {
  const res = await request.post('/order/order_import/detail', params);
  if (res.data.code === 1) {
    return res.data.data;
  }
  return Promise.reject(res.data?.msg || errortips);
}
export async function get_order_import_success_list(params) {
  const res = await request.post('/order/order_import/success_list', params);
  if (res.data.code === 1) {
    return res.data.data;
  }
  return Promise.reject(res.data?.msg || errortips);
}
export async function get_order_import_fail_list(params) {
  const res = await request.post('/order/order_import/fail_list', params);
  if (res.data.code === 1) {
    return res.data.data;
  }
  return Promise.reject(res.data?.msg || errortips);
}
export async function get_order_import_success_record(params) {
  const res = await request.post('/order/order_import/success_record', params);
  if (res.data.code === 1) {
    return res.data.data;
  }
  return Promise.reject(res.data?.msg || errortips);
}
export async function get_order_import_fail_record(params) {
  const res = await request.post('/order/order_import/fail_record', params);
  if (res.data.code === 1) {
    return res.data.data;
  }
  return Promise.reject(res.data?.msg || errortips);
}
export async function get_order_import_all_record(params) {
  const res = await request.post('/order/order_import/all_record', params);
  if (res.data.code === 1) {
    return res.data.data;
  }
  return Promise.reject(res.data?.msg || errortips);
}
